module.exports = options => {
    return async function gzip(ctx, next) {
        var pathname = ctx.request.url.split("?")[0]
        function isUrl(params) {
            let url = options.isURl
            console.log(url,pathname,'===---===')
            return url.some(x => {
                return x == params
            })
        }

        if (ctx.session.userinfo && ctx.session.userinfo.username) {
            var hasAuth=await ctx.service.admin.utlis.authAdmin();
            if(hasAuth){
                await next();
            }else{
                ctx.body="您没有权限访问这个地址";
            }
            // await next()
        } else {
            console.log(isUrl(pathname), 'isurl');
            if (isUrl(pathname)) {
                await next()
            } else {
                ctx.redirect(`/${options.pathname}/login`)
            }
        }

    };
};
